package qmm.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import qmm.dao.GoodsDao;
import qmm.dao.impl.GoodsDaoImpl;
import qmm.entity.Goods;

@WebServlet("/GoodsServlet")
public class GoodsServlet extends BaseServlet {
	private GoodsDao dao = new GoodsDaoImpl();
	public void findHot(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<Goods> list = dao.findHot();
		request.setAttribute("list", list);
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}
	
	public void findOne(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		int id = Integer.parseInt(request.getParameter("id"));
		Goods goods = dao.findById(id);
		request.setAttribute("goods", goods);
		request.getRequestDispatcher("product.jsp").forward(request, response);
	}
	

}
